/**********************************************
FileName	:	"CCreditsState.h"

Author Name	:	Ted Pereira (TP)

Purpose		:	Rolls the credits
***********************************************/
#include "CCredits.h"
#include "CGame.h"
#include "CMainMenuState.h"
#include "VIN_BitMapFont.h"

CCreditsState::CCreditsState()
{
	startPos = 0;
	imageID = -1;
}

CCreditsState::~CCreditsState()
{

}


void CCreditsState::Enter(void)
{
	startPos = 600;
	trigger = false;
	timer = 0.0f;
	imageID = CSGD_TextureManager::GetInstance()->LoadTexture("resource/Graphics/VindicatedLogo.png");
	VIN_SoundManager::GetInstance()->PlayBGM(BGM_CREDITS);
}
void CCreditsState::Update(float fElapsedTime)
{
	startPos -= 50 * fElapsedTime;
	if(trigger)
		timer += fElapsedTime;
}

bool CCreditsState::Input(void)
{
	if(CSGD_DirectInput::GetInstance()->KeyDown(DIK_ESCAPE))
		CGame::GetInstance()->ChangeState(CMainMenuState::GetInstance());
	return true;
}



void CCreditsState::Render(void)
{
	int pluser = 1;
	CSGD_Direct3D* p = CSGD_Direct3D::GetInstance();
	VIN_BitMapFont* b = VIN_BitMapFont::GetInstance();
	p->Clear();
	b->Render("Created By:",350,(int)startPos +25 * pluser++,1,D3DCOLOR_XRGB(255,0,255),GAMEFONT);
	b->Render("Vindicated Games",350,(int)startPos +25 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);

	b->Render("Team Members:",350,(int)startPos +50 * pluser++,1,D3DCOLOR_XRGB(255,0,255),GAMEFONT);
	b->Render("Kevin Jordan",350,(int)startPos +50 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);
	b->Render("Joe LaBella",350,(int)startPos +50 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);
	b->Render("Ted Pereira",350,(int)startPos +50 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);
	b->Render("Jayson Wu",350,(int)startPos +50 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);

	b->Render("Executive Producer:",350,(int)startPos +65 * pluser++,1,D3DCOLOR_XRGB(255,0,255),GAMEFONT);
	b->Render("John O'Leske",350,(int)startPos +65 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);

	b->Render("Associate Producer:",350,(int)startPos +65 * pluser++,1,D3DCOLOR_XRGB(255,0,255),GAMEFONT);
	b->Render("Ron Powell",350,(int)startPos +65 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);

	b->Render("Special Thanks:",350,(int)startPos +75 * pluser++,1,D3DCOLOR_XRGB(255,0,255),GAMEFONT);
	b->Render("Dave Brown",350,(int)startPos +75 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);
	b->Render("Steve Hamlin",350,(int)startPos +75 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);
	b->Render("Ron Powell",350,(int)startPos +75 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);
	b->Render("Rob Martinez",350,(int)startPos +75 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);
	b->Render("Sean Hathaway",350,(int)startPos +75 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);
	b->Render("Chris Jahosky",350,(int)startPos +75 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);
	b->Render("Caffiene",350,(int)startPos +75 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);
	b->Render("Google",350,(int)startPos +75 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);
	b->Render("ijji Lunia (sounds)",350,(int)startPos +75 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);
	b->Render("Japan. Get better :(",350,(int)startPos +75 * pluser++,1,D3DCOLOR_XRGB(0,255,0),GAMEFONT);


	float pos = startPos + 85 * pluser++;
	if(pos <= 100)
	{
		pos = 100;
		trigger = true;

		if(timer >= 4.8f)
		{
			CGame::GetInstance()->ChangeState(CMainMenuState::GetInstance());
			return;
		}
	}

	CSGD_TextureManager::GetInstance()->Draw(imageID, 30, (int)pos, 1.5f, 1.5f);


}

void CCreditsState::Exit(void)
{
	CSGD_TextureManager::GetInstance()->UnloadTexture(imageID);

}


CCreditsState* CCreditsState::GetInstance()
{
	static CCreditsState instance;
	return &instance;
}